package cn.jinjimi.framework.router.impl;

import cn.jinjimi.framework.router.Router;
import cn.jinjimi.app.bean.RouterConstants;
import cn.jinjimi.framework.router.RouterOptions;
import cn.jinjimi.app.bean.RouterService;

/**
 * Created by Hiro on 15/9/26.
 */
public class DirectTask implements IRTask {

    public final DirectRoute direct;

    public DirectTask(DirectRoute direct) {
        this.direct = direct;
    }

    @Override
    public void open(RouterOptions option) {
        Object targetRoute = RouterService.ROUTER_TABLE.get(direct.path);
        //防止循环跳转
        if (targetRoute != null && targetRoute instanceof DirectRoute) {
            return;
        }

        Router.create(option.getContext(), RouterConstants.getNativeRouter(direct.path)).addParam(option.getBundle()).open();
    }

}